home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / archivers / checkx / sources / startcode.a < prev    next >
Text File  |  1999-06-14  |  1KB  |  53 lines

  1.         INCLUDE    AINCLUDE:IncDirs.i
  2.         INCLUDE    exec/libraries.i
  3.         INCLUDE    exec/tasks.i
  4.         INCLUDE    exec/memory.i
  5.         INCLUDE    lvo.i
  6.  
  7.         XREF    @start
  8.  
  9. * Could not do that in main program, because of C language limitations
  10. *
  11. * This is not required (e.g. You can compile the main program without that
  12. * start header), but may increase stability for files with really deep
  13. * recursion (I have a file with up to 23 link levels).
  14.  
  15. STACKSIZE    EQU    10240
  16.  
  17.         MOVEA.L    4.W,A6
  18.         CMP.L    #37,LIB_VERSION(A6) * we need OS2.0 to use StackSwap
  19.         BLO.B    start
  20.         MOVE.L    #STACKSIZE,D2
  21.         SUBA.L    A1,A1
  22.         JSR    _LVOFindTask(A6)
  23.         MOVE.L    D0,A0
  24.         MOVE.L    TC_SPUPPER(A0),D0  * calculate current size
  25.         SUB.L    TC_SPLOWER(A0),D0
  26.         CMP.L    D2,D0
  27.         BGE.B    start           * enough ? then do nothing
  28.         MOVE.L    D2,D0
  29.         MOVEQ    #MEMF_PUBLIC,D1
  30.         JSR    _LVOAllocMem(A6)   * get memory
  31.         MOVE.L    D0,D3
  32.         BEQ.B    start           * failed ? call without StackSwap
  33.         LEA    -StackSwapStruct_SIZEOF(A7),A7
  34.         MOVE.L    A7,A4
  35.         MOVE.L    D0,stk_Lower(A4)   * initialize StackSwapStruct
  36.         ADD.L    D2,D0
  37.         MOVE.L    D0,stk_Upper(A4)
  38.         MOVE.L    D0,stk_Pointer(A4)
  39.         MOVEA.L    A4,A0
  40.         JSR    _LVOStackSwap(A6)  * swap stack
  41.         JSR    @start(PC)       * call main function
  42.         MOVE.L    D0,D6
  43.         MOVEA.L    A4,A0
  44.         JSR    _LVOStackSwap(A6)  * swap stack back
  45.         LEA    StackSwapStruct_SIZEOF(A7),A7
  46.         MOVEA.L    D3,A1
  47.         MOVE.L    D2,D0
  48.         JSR    _LVOFreeMem(A6)       * free stack
  49.         MOVE.L    D6,D0           * set return code
  50.         RTS
  51. start        JMP    @start(PC)
  52.         END
  53.